<?php
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
cfc('core')->checklogin();
set_html('title','单品销售额');
if($_RQ['op']=='main'){
	$member=$this->model('member')->checkmember();
	$member['level']=$this->get('level',array('uniacid'=>$_SESSION['uniacid'],'id'=>$member['level_id']));
	$return['setting']=$this->plugin_setting('page');
	$return['params']=array(
		'type'=>$_RQ['type']?:$member['level']['type'],
	);
	$member['level']['type']=$_RQ['type']?:$member['level']['type'];
	$return['total_price']=$this->model('model')->goods_allfee($member);
	$return['total_price2']=$this->model('model')->goods_allfee($member,0,1);
	$member['typetitle']=$this->level_types[$member['level']['type']];
	$return['member']=$member;
	$return['list']=array();
	exi($return);
}
if($_RQ['op']=='list'){
	$params=array('merchid'=>$_SESSION['onemerchid'],'uniacid'=>$_SESSION['uniacid']);
	$psize=20;
	$pindex=intval($_RQ['page'])?:1;
	$parameter=array(
		'params'=>$params,
		'limit'=>array($pindex,$psize),
		'orderby'=>'id desc',
	);
	$list=$this->get_list('goods',$parameter);
	if(!$list){
		exi('none');
	}
	$member=$this->model('member')->checkmember();
	$member['level']=$this->get('level',array('uniacid'=>$_SESSION['uniacid'],'id'=>$member['level_id']));
	$member['level']['type']=$_RQ['type']?:$member['level']['type'];
	$params=array('uniacid'=>$_SESSION['uniacid'],'ispay'=>1);
	foreach($list as &$item){
		$item['goods']=pdo_get('jy_weishop_goods',array('id'=>$item['goods_id']),array('title','image'));
		$item['total_price']=$this->model('model')->goods_allfee($member,0,'',$item['goods_id']);
		$item['total_price2']=$this->model('model')->goods_allfee($member,0,1,$item['goods_id']);
	}
	exi($list);
}
?>